<%--
  Created by IntelliJ IDEA.
  User: LENOVO
  Date: 2022/8/21
  Time: 18:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>

</head>

<body>
<div class="x-nav">
			<span class="layui-breadcrumb">
				<a href="">首页</a>
				<a href="">演示</a>
				<a>
					<cite>导航元素</cite></a>
			</span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <h1 align="center" style="font-size: 25px">管理员个人信息</h1>
    </div>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i
                        class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>姓名</th>
            <th>手机</th>
            <th>邮箱</th>
            <th>地址</th>
            <th>用户名</th>
            <th>加入时间</th>
            <th>角色</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="tb">


        </tbody>
    </table>
</div>
</body>
<script>
    layui.use('laydate', function() {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    //页面加载好就执行的函数
    $(function () {
        //发送请求的方法
        loadData();
    })

    //定义执行函数查全部
    function loadData() {
        $.ajax({
            url:"/user/managerList",
            type: "get",
            dataType: "json",
            success:function (rs) {
                //判断当前状态码是否为200、
                if (rs.code == 200) {
                    //渲染表格   采用html字符串拼接
                    var html = "";
                    //循环遍历渲染表格中的数据
                    // for (var i = 0; i < rs.data.list.length; i++) {
                        //6.渲染html拼接
                        html += "<tr>"
                            +"<td><div class=\"layui-unselect layui-form-checkbox\" lay-skin=\"primary\" data-id=' " + rs.data.userId + " '>" +
                            "<i class='layui-icon'>&#xe605;</i></div></td>"
                            + "<td>" + rs.data.userId + "</td>"
                            + "<td>" + rs.data.name + "</td>"
                            + "<td>" + rs.data.phone + "</td>"
                            + "<td>" + rs.data.email + "</td>"
                            + "<td>" + rs.data.address + "</td>"
                            + "<td>" + rs.data.username + "</td>"
                            + "<td style='display: none'>" + rs.data.password + "</td>"
                            + "<td style='display: none'>" + rs.data.sex + "</td>"
                            + "<td>" + rs.data.joinDate + "</td>"
                            + "<td>" + "管理员" + "</td>"
                            + "<td class='td-manage'>"
                            + "<a title='编辑' onclick='update(this)' href='javaScript:;'>"+"<i class='layui-icon'>&#xe642;</i></a>"
                            + "<a title='删除' onclick='mem_delete(this)' href='javaScript:;'>"+"<i class='layui-icon'>&#xe640;</i></a>"
                            + "</td>"
                            + "</tr>"
                    // }
                    //7.将数据显示在表格上
                    $("#tb").html(html);
                }
            }
        })
    }

    //修改-数据回显将数据存入到cookie中，在其他页面获取并渲染到文本框
    function update(obj) {
        //获取选中行
        var userId = $(obj).parent().parent().find("td").eq(1).text();
        localStorage.setItem("userId",userId);

        var name = $(obj).parent().parent().find("td").eq(2).text();
        localStorage.setItem("name",name);

        var phone = $(obj).parent().parent().find("td").eq(3).text();
        localStorage.setItem("phone",phone);

        var email = $(obj).parent().parent().find("td").eq(4).text();
        localStorage.setItem("email",email);

        var address = $(obj).parent().parent().find("td").eq(5).text();
        localStorage.setItem("address",address);

        var username = $(obj).parent().parent().find("td").eq(6).text();
        localStorage.setItem("username",username);

        var password = $(obj).parent().parent().find("td").eq(7).text();
        localStorage.setItem("password",password);

        var sex = $(obj).parent().parent().find("td").eq(8).text();
        localStorage.setItem("sex",sex);

        var rname = $(obj).parent().parent().find("td").eq(10).text();
        localStorage.setItem("rname",rname);

        //
        x_admin_show("修改用户","/user-upd",600,400)

    }

</script>
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
</html>
